import AMap from "AMap";
//startLngLat 起点 类型数组 [经度,纬度]
//endLngLat   重点 类型数组 [经度,纬度]
export const navigationResult=async function(startLngLat,endLngLat){
    let res;
    await FOO()
   async function FOO(){
        await new Promise((resolve, reject) =>{
            AMap.plugin("AMap.Driving", function () {
                var driving = new AMap.Driving({
                  // 驾车路线规划策略，AMap.DrivingPolicy.LEAST_TIME是最快捷模式
                  policy: AMap.DrivingPolicy.LEAST_TIME,
                });
                driving.search(startLngLat, endLngLat, function (status, result) {
                  // 未出错时，result即是对应的路线规划方案
                  //利用Promise抛出结果
                  resolve(result.routes[0])
                });
              });
        }).then((msg)=>{
            res=msg
        });
    }
    return res
}